package glashart2xmltv;

import static glashart2xmltv.Grabber.MAX_DAY_SEGMENTS;

import java.util.Collection;
import java.util.Date;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * 
 * @author Jeroen Peschier
 * @version $Id: ChannelLister.java 2 2013-02-09 11:54:47Z peschierj@gmail.com $
 */
public class ChannelLister {
	
	private static final Log log = LogFactory.getLog(ChannelLister.class);
	
	public static void main(String[] args) {
		try {
			if (args.length >= 1) {
				Config.initialise(args[0]);
			} else {
				Config.initialise();
			}
			Grabber grabber = new Grabber();
			Date today = new Date();
			Set<String> channels = new HashSet<String>();
			for (int daySegment = 0; daySegment < MAX_DAY_SEGMENTS; daySegment++) {
				Map<String, Collection<GuideEntry>> entries = grabber.getBaseGuideEntries(today, daySegment);
				channels.addAll(entries.keySet());
			}

			for (String channel : channels) {
				System.out.println(channel);
			}
		} catch (Exception e) {
			log.error("Failed to create channel list.", e);
		}
	}
}